package com.crr.controller;

import cn.hutool.core.bean.BeanUtil;
import com.crr.bean.CInquiry;
import com.crr.common.bean.PageBean;
import com.crr.common.bean.ResultBean;
import com.crr.common.controller.BaseController;
import com.crr.query.CInquiryQuery;
import com.crr.service.CInquiryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "客户端询价")
@RestController
@RequestMapping("/v1")
public class CInquiryController extends BaseController {
    @Autowired
    CInquiryService cInquiryService;

    @ApiOperation("询价列表")
    @PostMapping("/inquiry/query")
    public ResultBean query(@RequestBody CInquiryQuery cInquiryQuery){
        PageBean bean = cInquiryService.query(BeanUtil.beanToMap(cInquiryQuery));
        return success("询价列表",bean);
    }

    @ApiOperation("添加询价单")
    @PostMapping("/inquiry")
    public ResultBean save(@RequestBody CInquiry cInquiry){
        int res = cInquiryService.save(cInquiry);
        return saveResult(res);
    }


}
